<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>文件管理器</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script src="static/fw/plugin/jquery/1.11.0/jquery-1.11.0.min.js"></script>
<script
	src="static/fw/plugin/jquery/jquery-migrate/jquery-migrate-1.2.1.js"></script>
<script type="text/javascript"
	src="static/fw/plugin/file/ckfinder/ckfinder.js"></script>
</head>
<body>
	<p style="padding-left: 30px; padding-right: 30px;">
		<script type="text/javascript">
			// This is a sample function which is called when a file is selected in CKFinder.
			function showFileInfo(fileUrl, data, allFiles) {
				var msg = '';
				var url = fileUrl;
				msg += '<div><img id="cboxPhoto" width="200" height="200" alt="" src="'
						+ url + '"/></div>';
				msg += '<b>图片路径:</b> ' + fileUrl
						+ '<br />';
				// Display additional information available in the "data" object.
				// For example, the size of a file (in KB) is available in the data["fileSize"] variable.
				if (fileUrl != data['fileUrl'])
					msg += '<b>图片保存路径:</b> ' + data['fileUrl'] + '<br />';
				msg += '<b>图片大小:</b> ' + data['fileSize'] + 'KB<br />';
				msg += '<b>最后修改时间:</b> ' + data['fileDate'];

				if (allFiles.length > 1) {
					msg += '<br /><br /><b>Selected files:</b><br /><br />';
					msg += '<ul style="padding-left:20px">';
					for (var i = 0; i < allFiles.length; i++) {
						// See also allFiles[i].url
						msg += '<li>' + allFiles[i].data['fileUrl'] + ' ('
								+ allFiles[i].data['fileSize'] + 'KB)</li>';
					}
					msg += '</ul>';
				}

				// this = CKFinderAPI object
				this.openMsgDialog("文件信息", msg);
			}
			// See http://docs.cksource.com/ckfinder_2.x_api/symbols/CKFinder.html#.addPlugin
			// See http://docs.cksource.com/CKFinder_2.x/Developers_Guide/PHP/Plugins/Writing_JavaScript
			CKFinder
					.addPlugin(
							'basketTest',
							{
								basketToolbar : [ [
										// UI type have to be in string form.
										'basketTest',
										{
											label : 'Basket Test',
											icon : false,
											onClick : function() {
												alert('My own function executed after pressing Basket Test.');
											}
										} ] ],
								basketFileContextMenu : [ [
										'basketTest',
										{
											label : 'Basket Test',
											onClick : function() {
												alert('My own function executed after selecting Basket Test in the context menu.');
											},
											group : 'file1'
										} ] ]
							});
			// You can use the "CKFinder" class to render CKFinder in a page:
			var finder = new CKFinder();
			// The path for the installation of CKFinder (default = "/ckfinder/").
			finder.basePath = 'static/fw/plugin/file/ckfinder';
			finder.width = '98%';
			// The default height is 400.
			finder.height = document.documentElement.clientHeight - 50;
			// This is a sample function which is called when a file is selected in CKFinder.
			finder.selectActionFunction = showFileInfo;
			finder.callback = function(api) {
				// Add new sidebar tool space (with layout).
				var toolId = api.addToolPanel();
				api.hideTool(toolId);

				// Add new file context menu option.
				var sampleFileContextMenu = {
					label : '下载 test',
					command : 'batchdownload',
					group : 'file3'
				};
				api
						.addFileContextMenuOption(
								sampleFileContextMenu,
								function(api, file) {
									var markup = "<h3>Selected file</h3><p>You've selected file &quot;"
											+ file.folder.getPath()
											+ file.name
											+ "&quot;</p>";

									api.document.getElementById(toolId).innerHTML = markup;
									api.showTool(toolId);

									api
											.openMsgDialog(
													"",
													"Take a look at the bottom of left sidebar - it contains information about selected file.");
								});

				// Add new folder context menu option.
				var sampleFolderContextMenu = {
					label : '下载test',
					command : 'batchdownload',
					group : 'folder3'
				};
				api
						.addFolderContextMenuOption(
								sampleFolderContextMenu,
								function(api, folder) {
									var markup = "<h3>Selected folder</h3><p>You've selected folder &quot;"
											+ folder.getPath() + "&quot;</p>";

									api.document.getElementById(toolId).innerHTML = markup;
									api.showTool(toolId);

									api
											.openMsgDialog(
													"",
													"Take a look at the bottom of left sidebar - it contains information about selected folder.");
								});
			};
			finder.create();

			// It can also be done in a single line, calling the "static"
			// create( basePath, width, height, selectActionFunction ) function:
			// CKFinder.create( '../', null, null, showFileInfo );

			// The "create" function can also accept an object as the only argument.
			// CKFinder.create( { basePath : '../', selectActionFunction : showFileInfo } );
			var resized = false;
			/*window.onresize = function(){
				if(!resized){
					resized = true;
					setTimeout(function(){
						finder.height = document.documentElement.clientHeight-50;
						finder.create();
						resized = false;
					}, 500); 
				}
			}*/
		</script>
	</p>
</body>
</html>
